// CLaserCodeElementTimeDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Lightning.h"
#include "CLaserCodeElementTimeDlg.h"
#include "afxdialogex.h"


// CLaserCodeElementTimeDlg dialog

IMPLEMENT_DYNAMIC(CLaserCodeElementTimeDlg, CDialogEx)

CLaserCodeElementTimeDlg::CLaserCodeElementTimeDlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(CLaserCodeElementTimeDlg::IDD, pParent)
{
	m_nTimeType = 0;
	m_pAutoCode = NULL;
}

CLaserCodeElementTimeDlg::~CLaserCodeElementTimeDlg()
{
}

void CLaserCodeElementTimeDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Radio(pDX, ID_ELEMENT_TIME_HOUR_W, m_nTimeType);
	DDV_MinMaxInt(pDX, m_nTimeType, 0, 4);
}


BEGIN_MESSAGE_MAP(CLaserCodeElementTimeDlg, CDialogEx)
	ON_WM_CLOSE()
END_MESSAGE_MAP()


// CLaserCodeElementTimeDlg message handlers
void CLaserCodeElementTimeDlg::UpdateControlValue()
{
	UpdateData(TRUE);
	m_pAutoCode->SetTimeAutoCode(m_nTimeType);
}

void CLaserCodeElementTimeDlg::OnClose()
{
	// TODO: Add your message handler code here and/or call default

	CDialogEx::OnClose();
}


BOOL CLaserCodeElementTimeDlg::PreTranslateMessage(MSG* pMsg)
{
	// TODO: Add your specialized code here and/or call the base class
	if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)
	{
		return TRUE;
	}
	return CDialogEx::PreTranslateMessage(pMsg);
}


BOOL CLaserCodeElementTimeDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  Add extra initialization here
	UINT nType = -1;
	m_pAutoCode->GetTimeAutoCode(nType);
	m_nTimeType = (int)nType;
	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
